#{extends 'main.html' /} #{set title:'Home' /}
<!-- This is the page where people can see public comments.
@author Rana A. Zakaria
-->
<head>
<script type="text/javascript">
	function confirm_delete() {
		var r = confirm("Are you sure you want to delete this comment?!");
		if (r == true) {
			// alert("you have successfully deleted the comment");
			return true
		} else
			return false;
	}
</script>
</head>
<body>
	<h2>Public Comments:</h2>
	#{ifnot publicComments}
	<p>There are no comments on this tutorial yet.</p>
	#{/ifnot} #{else} #{list items: publicComments, as:'pc'}
	<ul>
		<li>
			<h2>${pc.toString()}</h2>
		</li>
	</ul>

	#{ if Long.parseLong(session.get("RegisteredUserId")) == pc.commentorId
	|| canDelete}
	<form action="@{Tutorials.deleteComment()}" method="POST">
		<div id="${pc.id}">
			<button name="commentID" type="submit" value="${pc.id}">delete</button>
		</div>
	</form>

	#{/if} #{/list} #{/else}

	<a href="@{Tutorials.tutorialPage(tutorialId)}">Back to Tutorial</a>

</body>
